package cn.com.cetccst.messagecenter.inboxmessage;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;

import java.text.SimpleDateFormat;

import cn.com.cetccst.datacenter.message.entity.InboxMessageEntity;
import cn.com.cetccst.messagecenter.BR;
import cn.com.cetccst.messagecenter.R;
import cn.com.cetccst.messagecenter.databinding.AdapterInboxMessageItemBinding;
import cn.com.cetccst.uicomponents.binding.recyclerview.SimpleDataBindingAdapter;

public class InboxMessageAdapter extends SimpleDataBindingAdapter<InboxMessageEntity, AdapterInboxMessageItemBinding> {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm");

    public InboxMessageAdapter(Context context) {
        super(context, R.layout.adapter_inbox_message_item, new DiffUtil.ItemCallback<InboxMessageEntity>() {
            @Override
            public boolean areItemsTheSame(@NonNull InboxMessageEntity oldItem, @NonNull InboxMessageEntity newItem) {
                return oldItem.getId() == newItem.getId();
            }

            @Override
            public boolean areContentsTheSame(@NonNull InboxMessageEntity oldItem, @NonNull InboxMessageEntity newItem) {
                return oldItem.getId() == newItem.getId();
            }
        });
    }

    @Override
    protected void onBindItem(AdapterInboxMessageItemBinding binding, InboxMessageEntity item, RecyclerView.ViewHolder holder) {
        binding.setVariable(BR.dateFormat, simpleDateFormat);
        binding.setEntity(item);

        //todo
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
    }
}
